package com.man.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.man.bean.AdminMan;
import com.man.dao.AdminDao;



/**
 * Servlet implementation class RegistServlet
 */
@WebServlet("/Register")
public class RegistServlet extends HttpServlet {
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		
		
		String name = request.getParameter("account");//获取账号
		String password = request.getParameter("password");//获取密码
		String password1 = request.getParameter("password1");//获取密码
		String pow = request.getParameter("pow");//获取密码
		AdminMan adminman=new AdminMan(name,password,pow);
		int num=0;
		num = new AdminDao().saveAdmin(adminman);
		if(num==0) {
			request.getSession().setAttribute("admin", "注册失败");
		}else {
			request.getSession().setAttribute("admin", "注册成功");
		}
		response.sendRedirect("Register.jsp");

	}

}
